Question about [Pure] methods

Posted by devoured elysium on Stack Overflow See other posts from Stack Overflow or by devoured elysium
Published on 2010-05-07T04:52:39Z Indexed on 2010/05/07 4:58 UTC
Read the original article Hit count: 273

Filed under:
|
|

Is the following method Pure? I'd say so, as it doesn't change in anyway the current class, thus, everything we can now currenly "see" in the class, before running this method will still be exactly the same after. Am I correct?

class Set {
    ...
    public ISet<T> UnionWith(ISet<T> set) {
       ISet<T> unionSet = ...

        foreach (Element element in this) {
            unionSet.Add(element);
        }

        foreach (Element element in set) {
           unionSet.Add(element);
        }

        return unionSet;
    }
}

© Stack Overflow or respective owner

Related posts about c#

Related posts about code-contracts